package com.zhhh.repository;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.zhhh.domain.Store;

import java.util.List;

/**
 */
public interface StoreRepository extends CrudRepository<Store, Integer> {

	// 此方法通过HQL语句内连接查询店铺id=?中的所有商品
	@Query("select distinct s from Store s inner join s.shops where s.id = :id")
	List<Store> findByShopList(@Param("id")Integer id,Pageable pageable);
	
	@Query("select s from Store s")
	List<Store> findByShopList(Pageable pageable);
	
	//使用SQL语句查询
	@Query(value = "select * from tb_store",nativeQuery = true)
	List<Store> findByShopList2();
	
}
